<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" href="css/base.css" />
		<link rel="stylesheet" href="css/m.css" />
		<link rel="stylesheet" href="css/forum_details.css" />
	</head>

	<body>
			<header>
			<div class="tophead">
				<div class="logo">
					<a href="#">世说新语</a>
				</div>
				<div id="mnav">
					<h2><span class="navicon"></span></h2>
					<ul>
						<li>
							<a href="#">网站首页</a>
						</li>
						<li>
							<a href="thrift_shop.html">二手商城</a>
						</li>
						<li>
							<a href="forum.html">论坛</a>
						</li>
						<li>
							<a href="endless_study.html">学无止境</a>
						</li>
						<li>
							<a href="#">注册</a>
						</li>
						<li>
							<a href="#">登录</a>
						</li>
					</ul>
				</div>
				<nav class="topnav" id="topnav">
					<ul>
						<li class="topnav_li user_function_li">
							<a class="topnav_a" href="#">
								<img src="img/a2.jpg" class="user_img" />
							</a>
							<div class="user_function_div">
								<div class="user_function_img_parent">
									<img src="img/a2.jpg" class="user_img" />
									<h3 class="user_name">行船全靠浪</h3>
								</div>
								<div>
									<ul class="user_function_ul">
										<li>
											<a href="#">个人中心</a>
										</li>
										<li>
											<a href="#">文章管理</a>
										</li>
										<li>
											<a href="#">贴文管理</a>
										</li>
										<li>
											<a href="#">商城管理</a>
										</li>
									</ul>
								</div>
								<a class="user_logout" href="#">安全退出</a>
							</div>
						</li>
						<li class="topnav_li">
							<a class="topnav_a" href="#">注册</a>
						</li>
						<li class="topnav_li">
							<a class="topnav_a" href="endless_study.html">学无止境</a>
						</li>
						<li class="topnav_li">
							<a class="topnav_a" href="forum.html">论坛</a>
						</li>
						<li class="topnav_li">
							<a class="topnav_a" href="thrift_shop.html">二手商城</a>
						</li>

						<li class="topnav_li">
							<a class="topnav_a" href="#">网站首页</a>
						</li>

					</ul>
				</nav>
			</div>
		</header>
		<article class="forum_details_article">
			<div class="article_top">
				<span>
					<b class="all_reply_num">13</b>回帖
				</span>
				<span>
					共<b class="all_reply_pages">1</b>页
				</span>
				<a href="forum.html">&lt;返回论坛</a>
			</div>
			<div class="article_left pull_left">
				<div class="article_left_top">
					<h4 class="pull_left article_theme">论QQSG的JS如何达到第一人</h4>
					<span class="pull_right">
						<a href="#" class="only_see_starter">只看楼主</a>
						<a href="#" class="reply_a"><i></i>回复</a>
					</span>
				</div>
				<div class="article_content">
					<div class="post_starter">
						<div class="starter_left pull_left">
							<span class="starter_logo"></span>
							<a href="#"><img class="starter_img" src="img/avatar.jpg" /></a>
							<h4 class="starter_name">行船全靠浪</h4>
							<span></span>
						</div>
						<div class="starter_right pull_left">
							<p class="starter_article"></p>
							<p class="other_intro"><span class="floor_layer">楼主</span><span class="post_time">2018-06-02</span><span class="reply_span">回复(<b class="reply_num">1</b>)</span></p>						
						</div>
					</div>
				</div>
				<div class="pagelist">

					<a class="current_page">1</a>
					<a class="previous_page">上一页</a>
					<a class="next_page">下一页</a>
					<a class="last_page">尾页</a>

				</div>
			</div>
			<div class="article_right pull_left">
				<div class="user_forum_info">
					<h3>我在论坛</h3>
					<a href="#" class="user_forum_info_a pull_left">
						<img src="img/about.jpg" class="user_forum_info_img" />
					</a>
					<a href="#" class="user_forum_info_name pull_left">行船全靠浪</a>
				</div>
				<div class="forum_hot_article">
					<h3>论坛热议榜</h3>
					<ul>
						<li><span class="forum_hot_article_order forum_hot_article_order_active">1</span>
							<a href="#" class="forum_hot_article_a">黄河之水天上来</a><span class="forum_hot_article_num">20000</span></li>
						<li><span class="forum_hot_article_order forum_hot_article_order_active">2</span>
							<a href="#" class="forum_hot_article_a">故人西辞黄鹤楼</a><span class="forum_hot_article_num">10000</span></li>
						<li><span class="forum_hot_article_order forum_hot_article_order_active">3</span>
							<a href="#" class="forum_hot_article_a">孤帆远影碧空尽</a><span class="forum_hot_article_num">5000</span></li>
						<li><span class="forum_hot_article_order">4</span>
							<a href="#" class="forum_hot_article_a">唯见长江天际流</a><span class="forum_hot_article_num">2000</span></li>
						<li><span class="forum_hot_article_order">5</span>
							<a href="#" class="forum_hot_article_a">黄河之水天上来</a><span class="forum_hot_article_num">20000</span></li>
						<li><span class="forum_hot_article_order">6</span>
							<a href="#" class="forum_hot_article_a">故人西辞黄鹤楼</a><span class="forum_hot_article_num">10000</span></li>
						<li><span class="forum_hot_article_order">7</span>
							<a href="#" class="forum_hot_article_a">孤帆远影碧空尽</a><span class="forum_hot_article_num">5000</span></li>
						<li><span class="forum_hot_article_order">8</span>
							<a href="#" class="forum_hot_article_a">唯见长江天际流</a><span class="forum_hot_article_num">2000</span></li>
					</ul>
				</div>
			</div>
		</article>

		<div id="f_editor">
			<h3 class="f_editor_title">发表回复</h3>

			<div id="editor2_bar" class="editor2_bar"></div>
			<div id="editor2_content" class="editor2_content">

			</div>
			<div>
				<button id="editor2_submit">发表</button>
			</div>
		</div>
		<footer>
			<p>Design by
				<a href="/">琪哥</a>
				<a href="/">初相遇 若重逢</a>
			</p>
		</footer>
		<script type="text/javascript" src="js/jquery.min.js"></script>
		<script type="text/javascript" src="js/wangEditor.min.js"></script>
		<script type="text/javascript" src="js/forum_details.js"></script>
		<script type="text/javascript">
			var E = window.wangEditor;
			var editor1 = new E('#editor1_bar', '#editor1_content');
			var editor2 = new E('#editor2_bar', '#editor2_content');

			editor2.customConfig.menus = editor1.customConfig.menus = [
				'italic',
				'underline',
				'foreColor', // 文字颜色
				'emoticon', // 表情
				'undo', // 撤销
			];
			editor1.create();
			editor2.create();
			
			//获取url中的参数
        function getUrlParam(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg);  //匹配目标参数
            if (r != null) 
            return unescape(r[2]);
             return null; //返回参数值
        }
      	function findForum(forum_id){
      		if(forum_id==null||forum_id==""){
      			return;
      		}
      		$.post(
      		"http://localhost:8080/campus/forum/findForum.do",
      		{"forum_id":forum_id
      		},
      		function(data){
      			$(data.forums).each(function(i,n){
      				$(".starter_article").eq(0).html(n.forum_content);//帖子的内容
      				$(".article_theme").eq(0).attr("value",n.forum_id);//帖子id
      			});
      			$(data.users).each(function(i,n){
      				$(".starter_name").eq(0).html(n.username);//楼主名字
      				$(".starter_name").eq(0).attr("value",n.user_id);//楼主id
      				
      			});
      			
      		},
      		"json"
      	);
      	}
      	findForum( getUrlParam("forum_id"));
      	
      	//页面最下边的主回复框
      	$("#editor2_submit").click(function(){
      		$.post(
      			"http://localhost:8080/campus/forumReply/addForumReply.do",
      			{"forum_id":$(".article_theme").eq(0).attr("value"),
      			"forum_reply_content":editor2.txt.html(),
      			"be_replyer_id":$(".starter_name").eq(0).attr("value"),
      			"if_floor":1
      			},
      			function(data){
      				if(data=="回复成功"){
      					return;
      				}else if(data="请先登录"){
      					alert("请先登录");
      					return;
      				}else{
      					alert("回复失败，请稍后重试");
      					return;
      				}
      			},
      			"json"
      		);
      	});
      	
      	function findAllForumReply(currentPage,count){
      		$.post(
      			"http://localhost:8080/campus/forumReply/findAllForumReply.do",
      			{"currentPage":currentPage,
      			"count":count
      			},
      			function(data){
      				$(data.forum_replys).each(function(i,n){
      					$(".article_content").append("	<div class='post_starter'>"+
						"<div class='starter_left pull_left'>"+
							"<a href='#'><img class='starter_img' src='img/avatar.jpg' /></a>"+
							"<h4 class='starter_name' ></h4>"+
						"</div>"+
						"<div class='starter_right pull_left'>"+
							"<p class='starter_article'>"+n.forum_reply_content+"</p>"+
							"<p class='other_intro'><span class='floor_layer'>"+(data.currentPage)*(i+1)+"楼</span>"+
							"<span class='post_time'>"+n.forum_reply_time+"</span>"+
							"<span class='reply_span'>回复(<b class='reply_num'>1</b>)</span></p>"+
							"<div class='reply_window'>"+
								"<ul>"+									
								"</ul>"+
								"<div class='reply_editor'>"+
									"<div id='editor1_bar' class='editor1_bar'></div>"+
									"<div id='editor1_content' class='editor1_content'>"+
									"</div>"+
									"<div><button class='editor1_submit'>发表</button></div>"+
								"</div>"+
							"</div>"+
						"</div>"+
					"</div>");
      				});
      			},
      			"json"
      		);
      	}
      	findAllForumReply(1,5);
		</script>
	</body>

</html>